<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://www.springframework.org/tags" prefix="spring" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ taglib tagdir="/WEB-INF/tags" prefix="tag"%>
<%@page contentType="text/html" import="uk.co.hs.constants.SecurityConstants" %>

<script>
function submitLogin()
{
  document.loginForm.submit();
}

function searchKeyPress(e)
{
  if (window.event)
  {
    e = window.event;
  }

  if (e.keyCode == 13)
  {
    submitLogin();
  }
}
</script>

<hr width="500px" style="margin-top:10px;margin-bottom:10px;color:#551A8B;background-color:#551A8B;height:2px"></hr>

<c:if test="${param.error == 'true'}">
<div style="margin-top:15px;margin-bottom:15px;">
  <span style="color:red;font-size:12px"><spring:message code="<%= SecurityConstants.GENERAL_FAILURE %>"/></span>
  <c:choose>
  <c:when test="${param.fail == 'active'}">
  <span style="color:red;font-size:12px"><spring:message code="<%= SecurityConstants.ACTIVE_MSG %>"/></span>
  </c:when>
  <c:when test="${param.fail == 'user'}">
  <span style="color:red;font-size:12px"><spring:message code="<%= SecurityConstants.USER_MSG %>"/></span>
  </c:when>
  <c:when test="${param.fail == 'password'}">
  <span style="color:red;font-size:12px"><spring:message code="<%= SecurityConstants.PASSWORD_MSG %>"/></span>
  </c:when>
  </c:choose>
</div>
</c:if>

<form id="loginForm" name="loginForm" action="j_spring_security_check" method="post">

  <div align="center">
  <table align="center">
    <tr>
      <th style="padding-right:20px;">Username</th>
      <td><input class="largeTextField" id="usernameField" type="text" name="j_username"/></td>
    </tr>
    <tr>
      <th style="padding-right:20px;">Password</th>
      <td><input class="largeTextField" id="passwordField" type="password" name="j_password" onkeypress="searchKeyPress(event);"/></td>
    </tr>
  </table>
  </div>

  <div align="center">
  <table align="center">
    <tr>
      <td>
        <a id="submitButton" class="button_input" onclick="submitLogin();" onmouseover="buttonHover(this);" onmouseout="buttonNormal(this);"><span><spring:message code="button.login"/></span></a>
      </td>
    </tr>
  </table>
  </div>

</form>

<hr width="500px" style="margin-top:10px;margin-bottom:10px;color:#551A8B;background-color:#551A8B;height:2px"></hr>

<script>document.getElementById('usernameField').focus();</script>
